#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
using namespace std;

#define rep(i,n) for (int i=0; i<n; i++)

int n, d;
int c;
int sol[1010];

int main() {
	c=0;
	scanf("%d %d", &n, &d);

	rep(i,n) scanf("%d", &sol[i]);

	rep(i,n) {
		rep(j,n) 
			if (i!=j && abs(sol[i]-sol[j])<=d) c++;
	}

	printf("%d\n", c); 

	return 0;
}
